package com.color.admin.common.core.base;


import com.color.admin.common.core.constant.Constant;
import com.color.admin.common.core.result.ResultData;

/**
 * @author HaiQiu
 * @date 2021/12/13
 * controller返回封装类
 */
public abstract class BaseController {

    public ResultData decide(String msg, int count) {
        return ResultData.ok(String.format(Constant.OPERATION, msg, count));
    }

    public ResultData decide(int count) {
        return count == 0 ? ResultData.fail() : ResultData.ok();
    }

    public ResultData decide(boolean b) {
        return b ? ResultData.ok() : ResultData.fail();
    }

    public ResultData decide(Object data) {
        return ResultData.ok(data);
    }

    public ResultData decide(String msg) {
        return ResultData.ok(msg);
    }

    public ResultData decide(String msg, Object data) {
        return ResultData.ok(msg, data);
    }
}
